package com.flexcloudsdk.datastore;
import java.util.logging.Logger;

import com.google.appengine.api.datastore.Blob;

public class CloudBlob {
	private static final Logger log = Logger.getLogger(CloudBlob.class.getName());
	private String sourceClass;
	private String sourceMethod;

	private Blob blob;
	
	public CloudBlob() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		sourceClass = CloudBlob.class.getName();
		log.info("CloudBlob has been created by BlazeDS");
	}
	
	public CloudBlob(byte[] bytes) {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		sourceClass = CloudBlob.class.getName();
		blob = new Blob(bytes);
	}
	
	@Override
	public boolean equals(Object object) {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

		return blob.equals(object);
	}
	
    public byte[] getBytes() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

     	return blob.getBytes();
    }
    
   @Override
public String toString() {
		sourceMethod = Thread.currentThread().getStackTrace()[1].getMethodName().toString();
		log.info("Executing: " + sourceClass + "." + sourceMethod);

	   return blob.toString();
   }
}
